package model

// User 用户表
type Cinfos struct {
	Cid       int    `json:"cid" form:"cid"`
	Clogo     string `json:"clogo" form:"clogo"`
	Apartment string `json:"apartment" form:"apartment"`
	Major     string `json:"major" form:"major"`
	Grade     string `json:"grade" form:"grade"`
	Class     string `json:"class" form:"class"`
}

func CinfosAll(cid string) ([]Cinfos, error) {
	mods := make([]Cinfos, 0, 4)
	err := DB.Select(&mods, "select * from cinfo where cid=?", cid)
	return mods, err
}
func CinfosOne(cid int) (c Cinfos, apartment, major, grade, class string, err error) {
	mods := make([]Cinfos, 0, 1)
	err = DB.Select(&mods, "select * from cinfo where cid=?", cid)
	// fmt.Println(mods[0].Apartment)
	if err == nil {
		apartment = mods[0].Apartment
		major = mods[0].Major
		grade = mods[0].Grade
		class = mods[0].Class
	} else {
		apartment = ""
		major = ""
		grade = ""
		class = ""
	}

	return mods[0], apartment, major, grade, class, err
	// return mods, err
}
